with open('Linux_log/secure', 'r') as file:
    Linux_data = file.readlines()

time = []
black_list = "Failed password for root from"
ssh = []
for data in Linux_data:
    time_month =  data.split(" ")[0]
    time_day = data.split(" ")[2]
    time_time = data.split(" ")[3]
    time.append(time_month +"/" + time_day + "/" +  time_time)
    if black_list in data:
        ssh.append(data)
        if len(ssh) > 4:
            print("检测到SSH攻击")
            attack_IP = data.split(" ")[11]
            ssh = []
